//
//  ZBDownloadManager.h
//  PaoPao
//
//  Created by xzb on 2018/4/21.
//  Copyright © 2018年 paopao. All rights reserved.
//

#import <Foundation/Foundation.h>


typedef NS_ENUM(NSInteger, ZBImageCacheType) {
    /**
     * The image wasn't available the SDWebImage caches, but was downloaded from the web.
     */
    ZBImageCacheTypeNone,
    /**
     * The image was obtained from the disk cache.
     */
    ZBImageCacheTypeDisk,
    /**
     * The image was obtained from the memory cache.
     */
    ZBImageCacheTypeMemory
};

typedef void(^ZBWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize);
typedef void(^ZBWebImageZBCompletionBlock)(UIImage *image, NSError *error, ZBImageCacheType cacheType, NSURL *imageURL);
typedef void(^ZBWebImageQueryCompletedBlock)(UIImage *image, ZBImageCacheType cacheType);
typedef UIImage *(^ZBWebImageTransformBlock)(UIImage *image, NSURL *url);


@interface ZBDownloadManager : NSObject

+ (instancetype)instance;


+ (void)ZB_downloadImageWithURL:(NSURL *)url completed:(ZBWebImageZBCompletionBlock)completedBlock;

+ (void)ZB_downloadImageWithURL:(NSURL *)url progress:(ZBWebImageDownloaderProgressBlock)progressBlock completed:(ZBWebImageZBCompletionBlock)completedBlock;

+ (void)ZB_queryCacheForURL:(NSURL *)url completed:(ZBWebImageQueryCompletedBlock)completedBlock;

+ (void)ZB_clear;

+ (void)ZB_clearAllOnCompletion:(void (^)(void))completion;

+ (void)ZB_clearDiskOnCompletion:(void (^)(void))completion;
@end
